package Com.javaserver.servlet;
import Com.javaserver.bean.admid;
import Com.javaserver.dao.admidserver;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/register")
public class zhuceServerlet extends HttpServlet {
    admidserver admidserver = new admidserver();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
String acct =req.getParameter("account");
String paww =req.getParameter("password");

     admid user=new admid(acct, paww);

        if (admidserver.register(user) == null) {
            req.getSession().setAttribute("msg", "注册失败");
            resp.sendRedirect(req.getContextPath() + "/zhuce.jsp");
        } else {
            req.getSession().setAttribute("msg", "注册成功");
            resp.sendRedirect(req.getContextPath() + "/main.jsp");
        }
    }
}
